package com.tedu.bill.demo3;

/**
 * Author：毕龙
 * Date: 2024/4/24 20:05
 */
public class TestFindStudent {
    public static void main(String[] args) {
        Student[] students = {
                new Student("小华", 18, 99),
                new Student("曹洋", 19, 89),
                new Student("朱琳", 20, 79),
        };
       /* Student student = find(students);
        System.out.println(student);
        Student student1 = find(students,79,"朱琳");
        System.out.println(student1);*/
        //接口的回调 ：先有接口的调用 再有接口的实现
        StudentFilter sf = null;
        sf = new Student99();
        Student student = find(students, sf);
        System.out.println(student);
        sf = new StudentZhuLin();
        student = find(students, sf);
        System.out.println(student);
        sf = new StundetAgeScore();
        student = find(students, sf);
        System.out.println(student);


    }

  /*  public static Student find(Student[] students){
        for (int i = 0; i < students.length; i++) {
            if(students[i].getScore() == 99){
                return students[i];
            }
        }
        return null;
    }
    public static Student find(Student[] students,double score,String name){
        for (int i = 0; i < students.length; i++) {
            if(students[i].getScore() == score && students[i].getName().equals(name)){
                return students[i];
            }
        }
        return null;
    }*/

    public static Student find(Student[] students,StudentFilter sf){
        for (int i = 0; i < students.length; i++) {
           if(sf.filter(students[i])){
               return students[i];
           }
        }
        return null;
    }
}
